package test5.lupeng.jf.com.teamdemo.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;

import java.util.ArrayList;
import java.util.List;

import test5.lupeng.jf.com.teamdemo.R;
import test5.lupeng.jf.com.teamdemo.untils.GlideCircleTransform;

/**
 * Created by snownight on 2017/8/1.
 */

public class ImageAdapter extends RecyclerView.Adapter {

    List<String> list;

    public ImageAdapter(List<String> list) {
        this.list = list;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_imagelayout, parent, false);
        ImageViewHolder holder = new ImageViewHolder(view);
        return holder;
    }

    public class ImageViewHolder extends RecyclerView.ViewHolder{

        private final ImageView image;

        public ImageViewHolder(View itemView) {
            super(itemView);
            image = itemView.findViewById(R.id.image);
        }
    }


    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        ImageViewHolder holder1 = (ImageViewHolder) holder;
        String s = list.get(position);

        Glide.with(holder1.itemView.getContext())
                .load(s)
                .centerCrop()
                .into( holder1.image);
    }

    @Override
    public int getItemCount() {
        return list.size();
    }
}
